<template>
	<view class="container">
		<scroll-view scroll-y show-scrollbar>
			<view v-for="(img, index) in imageList" :key="index">
				<image :src="img" mode="widthFix" lazy-load @click="priviewBigImage(index)" style="width: 100%;"></image>
			</view>
		</scroll-view>
		<view class="list-content">
			<back-top :src="backTop.src"  :scrollTop="backTop.scrollTop"></back-top>
		</view>
	</view>
</template>

<script>
	import $ from "@/static/js/jquery-3.5.1.min.js"
	export default {
		data() {
			return {
				backTop: {
					src: '../../static/png/top.png',
					scrollTop: 0
				},
				imageList: [],
				currentTime: null,
				count: 30,
				cosplay: {
					link: null,
					userAgent: 'okhttp/3.8.1',
				},
			}
		},
		//3、监听滚动
		onPageScroll(e) {
			this.backTop.scrollTop = e.scrollTop;
		},
		created(){
			this.currentTime = new Date().getTime();
			this.cosplay.link = 'http://floor.huluxia.com/post/list/ANDROID/2.1?platform=2&cat_id=29&tag_id=2913&start='+ this.currentTime +'&count='+ this.count;
			this.requist();
		},
		onPullDownRefresh() {
			this.currentTime = new Date().getTime();
			this.imageList = [];
			this.requist();
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1200);
		},
		onReachBottom(){
			this.requireYestady();
		},
		methods: {
			requist(){
				this.http.httpRequest('/huluxia/getImage','post',this.cosplay).then(res => {
					this.imageList = res.data;
				})
			},
			priviewBigImage(index){
				uni.previewImage({
					current: index,
					urls: this.imageList
				});
			},
			// 获取前一天的数据
			requireYestady(){
				this.currentTime -= 24 * 60 * 60 * 60;
				this.cosplay.link = 'http://floor.huluxia.com/post/list/ANDROID/2.1?platform=2&cat_id=29&tag_id=2913&start='+ this.currentTime +'&count='+ this.count;
				this.requist();
			}
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
	
	.all-border{
		border: #000000 1rpx solid;
	}
</style>
